function downloadExl(data, type) {

            var keys = Object.keys(data[0]);
            var firstRow = {};
            keys.forEach(function (item) {
                firstRow[item] = item;
            });
            data.unshift(firstRow);

            var content = {};

            // 把json格式的数据转为excel的行列形式
            var sheetsData = data.map(function (item, rowIndex) {
                return keys.map(function (key, columnIndex) {
                    return Object.assign({}, {
                        value: item[key],
                        position: (columnIndex > 25 ? getCharCol(columnIndex) : String.fromCharCode(65 + columnIndex)) + (rowIndex + 1),
                    });
                });
            }).reduce(function (prev, next) {
                return prev.concat(next);
            });

            sheetsData.forEach(function (item, index) {
                content[item.position] = { v: item.value };
            });

            //设置区域,比如表格从A1到D10,SheetNames:标题，
            var coordinate = Object.keys(content);
            var workBook = {
                SheetNames: ["helloSheet"],
                Sheets: {
                    "helloSheet": Object.assign({}, content, { "!ref": coordinate[0] + ":" + coordinate[coordinate.length - 1] }),
                }
            };
            //这里的数据是用来定义导出的格式类型
            var excelData = XLSX.write(workBook, { bookType: "xlsx", bookSST: false, type: "binary" });
            var blob = new Blob([string2ArrayBuffer(excelData)], { type: "" });
            saveAs(blob, "hello.xlsx");
        }
        //字符串转字符流
        function string2ArrayBuffer(s) {
            var buf = new ArrayBuffer(s.length);
            var view = new Uint8Array(buf);
            for (var i = 0; i != s.length; ++i) view[i] = s.charCodeAt(i) & 0xFF;
            return buf;
        }
        // 将指定的自然数转换为26进制表示。映射关系：[0-25] -> [A-Z]。
        function getCharCol(n) {
            let temCol = "",
                s = "",
                m = 0
            while (n > 0) {
                m = n % 26 + 1
                s = String.fromCharCode(m + 64) + s
                n = (n - m) / 26
            }
            return s
        }